import { InputQuestion, QuestionBase, SelectQuestion, TextQuestion } from '@/components/public-template';
import { TextTable } from '@/components/public-template';
import { TableBase } from '@/components/public-template';
import { Api as ApiStatement } from '@/config/api/watermark';
import { regExp } from '@/utils/regExp';

class HomeService {
  getQuestions() {
    const questions: QuestionBase<any>[] = [
      new TextQuestion({
        key: 'id',
        hide: true,
        value: null
      }),
      new InputQuestion({
        key: 'name',
        label: '文件夹名称',
        required: true,
        prompt: '请输入，长度不可超过100个字符',
        reg: regExp.len100,
        value: null
      }),
      new SelectQuestion({
        key: 'watermarkingId',
        value: null,
        label: '电子水印',
        type: 'search',
        state: {
          url: ApiStatement.watermarkPage,
          protType: 'post',
          nameKey: 'name',
          nameValue: 'id',
          params: {
            pageNumber: 1,
            pageSize: 999
          }
        }
      }),
      new TextQuestion({
        key: 'code',
        label: '编码',
        value: null
      }),
      new TextQuestion({
        key: 'size',
        label: '大小',
        value: null
      }),
      new InputQuestion({
        key: 'desc',
        label: '描述',
        value: null,
        reg: regExp.len200,
        prompt: '长度不可超过200个字符'
      })
    ];
    return questions;
  }
  getViewQuestions() {
    const questions: QuestionBase<any>[] = [
      new TextQuestion({
        key: 'name',
        label: '文件夹名称',
        value: null
      }),
      new TextQuestion({
        key: 'watermarkingIdName',
        label: '电子水印',
        value: null
      }),
      new TextQuestion({
        key: 'code',
        label: '编码',
        value: null
      }),
      new TextQuestion({
        key: 'size',
        label: '大小',
        value: null
      }),
      new TextQuestion({
        key: 'desc',
        label: '描述',
        value: null
      })
    ];
    return questions;
  }
  getTables() {
    const tables: TableBase<any>[] = [
      new TextTable({
        key: 'num',
        value: '序号',
        type: 'index',
        columns: {
          width: 70
        }
      }),
      new TextTable({
        key: 'lastStatus',
        value: '变更前状态',
        type: 'dictionary',
        state: {
          filterName: 'BOX_STATUS'
        }
      }),
      new TextTable({
        key: 'changeStatus',
        value: '变更后状态',
        type: 'dictionary',
        state: {
          filterName: 'BOX_STATUS'
        }
      }),
      new TextTable({
        key: 'reason',
        value: '状态变更原因'
      }),
      new TextTable({
        key: 'creatorName',
        value: '操作人'
      }),
      new TextTable({
        key: 'modifiedTime',
        value: '操作时间'
      })
    ];
    return tables;
  }
}

export default new HomeService();
